package com.gxa.luckin.order.repository;

import com.gxa.luckin.order.pojo.OrderStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

/**
 * @author: XHZ
 * @date: 15:58 2021/7/16
 */
public interface OrderStatusRepository extends JpaRepository<OrderStatus, Long> {
    @Query(nativeQuery = true, value = "UPDATE order_status SET status=?1 WHERE order_id=?2 and status=?3")
    @Modifying
    Integer changeOrderState(Integer nowStatus, String orderId, Integer oldStatus);

    @Query(nativeQuery = true, value = "select * from order_status where status=1 and last_pay_time<?1")
    List<OrderStatus> queryOrderStatusMorePayTime(Date nowDate);

    OrderStatus findOrderStatusByOrderId(String orderId);
}
